package com.zhiche.lisa.bms.controller.utils;

import com.zhiche.lisa.bms.service.utils.common.identityCodeUtil.CodeUtil;
import com.zhiche.lisa.core.enums.CommonEnum;
import com.zhiche.lisa.core.supports.RestfulResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: liuanshun
 * @Description:
 * @Date: Create in 15:29 2019/1/18
 */
@RestController
@RequestMapping("/utils")
@Api(value = "/utils", description = "工具类操作接口", tags = {"工具类操作接口"})
public class UtilsController {
    @Autowired
    private CodeUtil codeUtil;

    @ApiOperation(value = "删除code记录", notes = "删除code记录", httpMethod = "GET")
    @GetMapping("/removeCode/{codeTypeName}")
    public RestfulResponse<Boolean> exportResouce(@PathVariable String codeTypeName) {
        RestfulResponse<Boolean> restful = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
        try {
            restful.setData(codeUtil.removeServiceCode(codeTypeName));
        } catch (Exception e) {
            restful = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return restful;
    }
}
